<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <style>
    .dv {
      width: 100px;
      height: 100px;
      background: hotpink;
    }
  </style>
  <body>
    <div class="dv">
      <button id="btn">按钮</button>
    </div>
  </body>
</html>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
  $(".dv").click(function () {
    console.log(this);
  });
  $("#btn").click(function () {
    console.log(this);
  });
  //   clone(是否克隆元素本身的事件，是否克隆元素子节点的事件)
  let btn = $("#btn").clone(false, false);
  let dv = $(".dv").clone(true, true);
  console.log(btn);
  $("body").append(btn);
  $("body").append(dv);
</script>
